from typing import *

class Solution:
    def successfulPairs(self, spells: List[int], potions: List[int], success: int) -> List[int]:
        id = sorted(range(len(spells)),key=lambda k : spells[k],reverse=True)
        potions.sort()
        ans = [0] * len(spells)
        i = 0
        for v in id:
            while i < len(potions) and spells[v] * potions[i] < success:
                i+=1
            ans[v] = len(potions) - i
        return ans
s = Solution()
print(s.successfulPairs(spells = [5,1,3], potions = [1,2,3,4,5], success = 7))

from bisect import bisect_left
class Solution:
    def successfulPairs(self, spells: List[int], potions: List[int], success: int) -> List[int]:
        potions.sort()
        ans = []
        for v in spells:
            id = bisect_left(potions,(success + v -1) // v)
            ans.append(len(potions) - id)
        return ans
s = Solution()
print(s.successfulPairs(spells = [5,1,3], potions = [1,2,3,4,5], success = 7))